package cn.micai.base.io;

import java.io.File;

/**
 * 描述：How to check if a file exists in Java
 * <p>
 *
 * @author: 赵新国
 * @date: 2018/6/7 9:44
 */
public class FileExistsMain {

    public static void main(String [] args) {
        System.out.println("--------------------");
        // Read the file
        File file = new File("D://test.txt");
        if (file.exists()) {
            System.out.println("test.txt file exists");
        } else {
            System.out.println("test.txt file does not exist");
        }
        System.out.println("--------------------");
        File file1 = new File("D://test");
        if (file1.exists()) {
            System.out.println("test file exists");
        } else {
            System.out.println("test file does not exist");
        }
    }
}
